package Szadoban;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/** Class creating main game window */
public class GameWindow extends MainFrame implements ActionListener {

	/**
	 * 
	 * @param panel
	 * @param label
	 */
	JButton restart;

	private void Panelab(JPanel panel, JLabel label) {

		label.setFont(new Font("Arial", Font.BOLD, 20));
		panel.add(label);
	}

	/**
	 * Class constructor, creates window structure
	 */
	public GameWindow() {
		setSize(800, 800);
		setTitle("Sokoban");
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		Container c = new Container();
		c.setLayout(new BorderLayout(10, 10));

		JPanel rightp = new JPanel();
		JPanel timepanel = new JPanel();
		JPanel scorepanel = new JPanel();
		JPanel levelpanel = new JPanel();

		JLabel score = new JLabel("SCORE:", SwingConstants.CENTER);
		JLabel time = new JLabel("TIME:", SwingConstants.CENTER);
		JLabel counttime = new JLabel("00:00", SwingConstants.CENTER);
		JLabel countscore = new JLabel("0", SwingConstants.CENTER);
		JLabel level = new JLabel("LEVEL:", SwingConstants.CENTER);
		JLabel whichlevel = new JLabel("0", SwingConstants.CENTER);
		JButton restart = new JButton("RESTART");

		TestGame game = new TestGame();
		game.setOpaque(true);

		rightp.setLayout(new GridLayout(6, 1, 10, 50));
		c.add(game, BorderLayout.CENTER);
		c.add(rightp, BorderLayout.LINE_END);

		GridLayout gl = new GridLayout(3, 1, 10, 10);
		timepanel.setLayout(gl);
		scorepanel.setLayout(gl);
		levelpanel.setLayout(gl);
		restart.setLayout(gl);

		Panelab(timepanel, time);
		Panelab(timepanel, counttime);
		Panelab(scorepanel, score);
		Panelab(scorepanel, countscore);
		Panelab(levelpanel, level);
		Panelab(levelpanel, whichlevel);

		rightp.add(timepanel);// ,BorderLayout.PAGE_START);
		rightp.add(scorepanel);// ,BorderLayout.CENTER);
		rightp.add(levelpanel);// ,BorderLayout.PAGE_END);
		rightp.add(restart);

		this.add(c);
		

		this.setVisible(true);
		restart.addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		Object source = e.getSource();

		if (source == restart) {
			// dispose();
			// GameWindow gamewindow = new GameWindow();
		}

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		GameWindow game = new GameWindow();
	}
}
